Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Add basic unit tests for problem::normalized. #120

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Add basic unit tests for problem::normalized. #120

wants to merge 16 commits into from

Conversation

neduard
Copy link

@neduard neduard commented Mar 10, 2015

Unit test for problem::normalized.
Test that applying normalize to a problem with bounds (-1, 1) doesn't have any effect.
Ensure that no matter what the bounds, normalized.objfun(x) = original.objfun(denormalize(x))

This PR is part of issue #7

@neduard neduard changed the title DO NOT MERGE YET: Add basic unit test for problem::normalized. Add basic unit tests for problem::normalized. Mar 12, 2015
@neduard
Copy link
Author

neduard commented Mar 12, 2015

A couple of questions:

  1. should we include tests for normalized::compute_constraints_impl() ?
  2. normalized::denormalize(const decision_vector& x) does NOT check that x is actually normalized: https://github.com/esa/pagmo/blob/master/src/problem/normalized.cpp#L77-83 is this the correct behaviour?

@darioizzo
Copy link
Member

  1. Yes, same as objfun_impl
  2. good point, as the method is public a check and a pagmo_throw should be there. On the other hand, it is used by the private methods compute_constraints_impl and objfun_impl so this would trigger a lot of checks ... I doubt it would see any performance impact in any realistic case ....

// Test following invariant:
// normalized(prob).objfun(dv) is equal to
// prob.objfun(normalized(prob).denormalize(dv))
int test_normalized_invariant(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge the lines here 63 and 64 (I know I didn't give you a clear guidelines on character limit ;) )

Method/Functions commenting style is either: https://github.com/esa/pagmo/blob/master/src/problem/normalized.cpp#L35-L41
or triple slash like https://github.com/esa/pagmo/blob/master/src/problem/normalized.cpp#L58
Latter is fine for unit testing.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 445d66c on neduard:unit_test_normalize into 3ee3b0a on esa:master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants